% -*- mode: latex; fill-column: 80 -*-

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%s
% $Id: 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{article}

\usepackage[english,american]{babel}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstset{language=ruby, breaklines = true, breakindent=0pt, postbreak=\mbox{{\tiny$\rightarrow$}}, basicstyle=\small\ttfamily, commentstyle=\rmfamily\itshape,columns=flexible}

\usepackage{paralist} % compact enumerations, see TLC p 132

\usepackage{rotating}
\usepackage{array} % better tabular functions, see TLC p242
\usepackage{layout}

% new commands
\newcommand{\etal}{et~al.}
\newcommand{\eg}{e.\,g.\/}
\newcommand{\ie}{i.\,e.\/}
\newcommand{\etc}{etc.\/}
\newcommand{\vs}{vs.\/}
\newcommand{\cf}{cf.\/}

\newtheorem{example}{Example}[section]

\title{RuPeas Language Definition}
%

\author{Matthias Woehrle\\
Christian Plessl\\
}

\begin{document}
\maketitle




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RuPeas is a Domain Specific Language for analyzing distributed system event logs.
It is particularly focussed on wireless networked embedded systems or Wireless Sensor
Networks (WSNs), where the individuals nodes are embedded devices and thus have
constraints on the visibility of the individual execution.
Wireless communication and different logging policies infer different semantics of
the logged data.
As such RuPeas uses the EvAnT framework \ref{us}: formulating logging messages as events,
with clear format: an event-tuple of key-value pairs, where node and type are mandatory fields.
RuPeas implements EvAnT's novel operators for analyzing WSN event logs.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Goals}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Goals for Rupeas:
\begin{compactitem}
	\item Concise
	\item Ease of use
\end{compactitem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Rupeas Implementation}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

We have to differentiate between the underlying API for the operators and the
higher level DSL using the basic operators.

However the underlying API must be fine granular enough to support a DSL formulation.
To this end, the implementation of predicates and transformation should be decoupled.
There is some predicate method on event sets, which returns an array of event sets.
Then there is the transform function, which takes this array, a function description
and the policy concerning the old results, implemented as a symbol.
Iterative processing for the Fixed point processor is TDB.

The footprint of these methods is shown below:

\begin{lstlisting}[captionpos=b, caption=Filter Example in ruby, label=lst:Filter]
eventSet.predicate(k,&proc) #-> returns Array of eventSets
arrayOfEventSets.transform(:merge, &proc) #-> returns eventSets
\end{lstlisting}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Events and Event Sets}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsubsection{Events}

Events is a factory for typed events. As such events have a mandatory node identifier
and the type. The type defines the subclass the specific event adheres to.
Subclasses are built with the event definition and can subsequently be checked for
consistency.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Operators}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Rupeas implements EvAnT operators on as methods on event sets.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Partition}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The partition operator is simplified to a filter for a given partition.
The reason for the simplification is the goal of having the operators closed 
under the event set. When partitioning a set, the result is a collection of
event sets: in the previous python implementation of EvAnT this was a 
hash/dictionary. However, this introduces a previously external data type.
We refrain from this approach and rather provide a filter operator, which is
a subset of the filter, returning a (filtered) event set. In case partitions,
are needed iterating over the keys of an event set and filtering for individual
subsets may be used. Since further processing is still produced on event sets,
join operators are used to generate multi-key subsets.

\begin{example} [Rupeas Filter]
	A Filter for ...
\begin{lstlisting}[captionpos=b, caption=Filter Example in ruby, label=lst:Filter]
eventSet.class
\end{lstlisting}
\end{example}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Set Transformator}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The set transformator in EvAnT is a special case of a set processor, namely 
it considers processing of single events. As such, it is mostly used for
adding (and removing) information from each individual event of a selected 
set of events. For RuPeas, we leave the general concept of processing 
individual events to the set processor. However, we expose a convenience 
operator for the most typical use os a set transformator. Adding new keys
with a certain value to a given set r subset.

\begin{example} [Rupeas Filter]
	A Filter for ...
\begin{lstlisting}[captionpos=b, caption=Filter Example in ruby, label=lst:Filter]
eventSet.class
\end{lstlisting}
\end{example}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Set Processor}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{example} [Rupeas Set Processor]
	A Set Processor for ...
\begin{lstlisting}[captionpos=b, caption=Filter Example in ruby, label=lst:setproc]
eventSet.class
\end{lstlisting}
\end{example}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Fixed Point Processor}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{example} [Rupeas Fixed Point Processor]
	A Fixed Point Processor for ...
\begin{lstlisting}[captionpos=b, caption=Filter Example in ruby, label=lst:fpp]
eventSet.class
\end{lstlisting}
\end{example}


\end{document}

